package com.example.informationEntry.controller;

import com.example.informationEntry.entity.*;
import com.example.informationEntry.service.*;
import com.example.informationEntry.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * @version v1.0
 * @ProjectName: informationEntry
 * @ClassName: InformationEntryController
 * @Description: TODO(项目控制层Controller)
 * @Author: sunbo@pgytesting.cn
 * @Date: 2019/4/1 20:23
 */
@RestController
@RequestMapping("/informationentry")
public class InformationEntryController {


    /**
     * 管理员信息表服务层
     */
    @Autowired
    NaAdministratorUserService adminService;

    /**
     * 公钥私钥日志表服务层
     */
    @Autowired
    NaSecretService naSecretService;

    /**
     * 管理员token表服务层
     */
    @Autowired
    NaUserTokenService naUserTokenService;

    /**
     * 学期表服务层
     */
    @Autowired
    NaSemesterTableService naSemesterTableService;

    /**
     * 联系人服务层
     */
    @Autowired
    NaEmergencyContactRelationshipService naEmergencyContactRelationshipService;

    /**
     * 紧急联系人信息
     */
    @Autowired
    NaEmergencyContactInformationService naEmergencyContactInformationService;

    /**
     * 学历信息
     */
    @Autowired
    NaEducationService naEducationService;

    /**
     * 入学类型
     */
    @Autowired
    NaAdmissionTypeService naAdmissionTypeService;

    /**
     * 宿舍信息
     */
    @Autowired
    NaDormitoryInformationService naDormitoryInformationService;

    /**
     * 学生缴纳学费信息
     */
    @Autowired
    NaTuitionService naTuitionService;

    /**
     * 学费基准信息
     */
    @Autowired
    NaTuitionFeeScheduleService naTuitionFeeScheduleService;

    /**
     * 学费优惠信息
     */
    @Autowired
    NaDiscountInformationService naDiscountInformationService;


    /**
     * 学生信息
     */
    @Autowired
    NaStudentInformationService naStudentInformationService;

    /**
     * 日志
     */
    private static Logger log = LoggerFactory.getLogger(InformationEntryController.class);


    /**
     * @param @param []
     * @return @return java.util.Map
     * @throws
     * @Title: encryptionTest
     * @Description: TODO(加密测试接口)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/9 10:56
     */
    @RequestMapping(value = "/encryption", method = RequestMethod.POST)
    public Map<String, Object> encryptionTest(@RequestBody Map<String, String> param) throws Exception {
        Map<String, String> map = new HashMap<>();
        log.info(
                "\n****************************************************************************************\n"
                        +
                        "*                   调用加密测试接口，此接口仅供测试调取明文加密操作                            *\n"
                        +
                        "****************************************************************************************");
        if ("RSA".equals(param.get("encryptionType").toUpperCase())) {
            log.info("调用RSA加密进行加密数据");
            String publicKey = param.get("publicKey");
            String encryptionData = param.get("encryptionData");
            map.put("oldEncryptionData", encryptionData);
            map.put("newEncryptionData", RSAUtils.publicEncrypt(encryptionData, RSAUtils.getPublicKey(publicKey)));
            return ResponseMessage.isSuccess(map, "加密成功，返回加密数据");
        } else if ("MD5".equals(param.get("encryptionType").toUpperCase())) {
            log.info("调用MD5加密进行加密数据");
            map.put("oldEncryptionData", param.get("encryptionData"));
            map.put("newEncryptionData", UtilMethod.md5Encryption(param.get("encryptionData")));
            return ResponseMessage.isSuccess(map, "加密成功，返回加密数据");
        } else {
            log.info("加密类型错误，请检查参数");
            return ResponseMessage.isError("加密类型错误，请检查参数，请输入RSA或者MD5");
        }
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: isMobile
     * @Description: TODO(验证手机号)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 20:08
     */
    @RequestMapping(value = "isMobile", method = RequestMethod.POST)
    public Map isMobile(@RequestBody Map<String, String> paraMap) {
        if (ValidateUtils.isMobile(paraMap.get("userPhone"))) {
            return ResponseMessage.isSuccess("手机号验证成功");
        }
        return ResponseMessage.isError("手机号验证失败");
    }


    /**
     * @param @param [param]
     * @return @return java.util.Map
     * @throws
     * @Title: RSAencryption
     * @Description: TODO(获取公钥接口)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/8 16:52
     */
    @RequestMapping(value = "/publicKey", method = RequestMethod.POST)
    public Map<String, Object> RSAencryption(@RequestBody Map<String, String> param) {
        log.info("调用RAS加密接口进行数据私钥，公钥生成");
        //进行登录类型判断
//        NaAdministratorUser admin = new NaAdministratorUser();
        Map<String, String> map = new HashMap<String, String>();
//        admin.setUserPhone(param.get("userName"));
//        log.info("用户使用用户名登陆，则查询用户手机号，进行公钥查询");
//        try {
//            admin = adminService.queryById(admin);
//            if (admin == null){
//                admin.setUserPhone(param.get("userName"));
//            }
//        } catch (Exception e) {
//            log.error(e.getMessage());
//            return ResponseMessage.isSQLException();
//        }
        NaSecret naSecret;
        try {
            naSecret = naSecretService.queryById(param.get("userName"));
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        map.put("userName", naSecret.getAccount());
        map.put("publicKey", naSecret.getAccountPublicKey());
        return ResponseMessage.isSuccess(map, "公钥查询成功，返回公钥。");
    }


    /**
     * @param @param
     * @return @return
     * @throws
     * @Title: getLohin
     * @Description: TODO(管理员新增)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/4 16:20
     */
    @RequestMapping(value = "/regis", method = RequestMethod.POST)
    public Map getRegistration(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaAdministratorUser admin = new NaAdministratorUser();
        // 对请求参数进行对象转换
        admin.setUserPhone(paraMap.get("newUserPhone"));
        // 顺序不可乱
        NaAdministratorUser administratorUser = adminService.queryById(admin);
        admin.setUserName(paraMap.get("newUserName"));
        admin.setAccountStatus("100001");
        // 要对密码进行解密处理
        // 查询到此账号的私钥，进行对应私钥解密
        NaSecret naSecret = naSecretService.queryById(admin.getUserPhone());
        try {
            String decodedData = RSAUtils.privateDecrypt(paraMap.get("newPassWord"), RSAUtils.getPrivateKey(naSecret.getAccountPrivateKey()));
            log.info("进行密码MD5加盐加密处理");
            admin.setUserPassword(UtilMethod.md5Encryption(decodedData));
            log.info("对管理员进行验证是否唯一");
            if (administratorUser != null) {
                if (admin.getUserPhone().equalsIgnoreCase(administratorUser.getUserPhone())) {
                    return ResponseMessage.isException("管理员手机号重复");
                }
            }
            adminService.insert(admin);
            return ResponseMessage.isSuccess("管理员" + admin.getUserName() + "信息添加成功");
        } catch (Exception e) {
            log.error("获取私钥对象错误：" + e.getMessage());
        }
        // 调用服务层返回对应参数
        return ResponseMessage.isError("解密错误，请确认密文和公钥是否对应");
    }


    /**
     * @param @param [pataMap]
     * @return @return java.util.Map
     * @throws
     * @Title: updateAdminUser
     * @Description: TODO(管理员密码自助修改)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/16 9:45
     */
    @RequestMapping(value = "/updateUser", method = RequestMethod.POST)
    public Map updateAdminUser(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaSecret naSecret;
        try {
            naSecret = naSecretService.queryById(paraMap.get("userName"));
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }

        String oldPassWord = paraMap.get("oldPassWord");
        String newPassWord = paraMap.get("newPassWord");
        try {
            oldPassWord = RSAUtils.privateDecrypt(oldPassWord, RSAUtils.getPrivateKey(naSecret.getAccountPrivateKey()));
            newPassWord = RSAUtils.privateDecrypt(newPassWord, RSAUtils.getPrivateKey(naSecret.getAccountPrivateKey()));
        } catch (Exception e) {
            log.error("获取私钥对象错误：" + e.getMessage());
        }
        NaAdministratorUser admin = new NaAdministratorUser();
        admin.setUserPhone(paraMap.get("userName"));
        admin = adminService.queryById(admin);
        if (admin != null) {
            if (admin.getUserPassword().equals(UtilMethod.md5Encryption(oldPassWord))) {
                log.info("密码验证成功，进行密码更新");
                admin.setUserPassword(UtilMethod.md5Encryption(newPassWord));
                adminService.update(admin);
                return ResponseMessage.isSuccess("密码更新成功，请使用新密码登陆");
            }
            return ResponseMessage.isError("密码验证失败，原密码不正确");
        }
        return ResponseMessage.isError("用户名不存在");
    }


    /**
     * @param @param [ParaMap]
     * @return @return java.util.Map
     * @throws
     * @Title: deleteAdminUser
     * @Description: TODO(管理员删除)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/16 10:46
     */
    @RequestMapping(value = "/delUser", method = RequestMethod.POST)
    public Map deleteAdminUser(@RequestBody Map<String, String> paraMap) {
        /**
         * 管理员删除
         * 实则是管理员数据保留，但是会更新管理员字段，对管理员的账号状态更新为封存
         */
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaAdministratorUser admin = new NaAdministratorUser();
        admin.setUserPhone(paraMap.get("userName"));
        admin = adminService.queryById(admin);
        if ("100011".equals(admin.getAccountStatus())) {
            return ResponseMessage.isError("用户已经被注销注销");
        }
        String passWord = paraMap.get("passWord");
        NaSecret naSecret;
        try {
            naSecret = naSecretService.queryById(admin.getUserPhone());
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }

        try {
            passWord = RSAUtils.privateDecrypt(passWord, RSAUtils.getPrivateKey(naSecret.getAccountPrivateKey()));
        } catch (Exception e) {
            log.error("获取私钥对象错误：" + e.getMessage());
            return ResponseMessage.isError("解密数据异常，检查加密参数是否正确");
        }
        log.info("进行密码MD5加盐加密处理");
        passWord = UtilMethod.md5Encryption(passWord);
        log.info("进行账号密码查询，验证是否一致");
        if (admin.getUserPassword().equals(passWord)) {
            NaAdministratorUser naAdministratorUser = new NaAdministratorUser();
            naAdministratorUser.setUserPhone(paraMap.get("delUserName"));
            naAdministratorUser.setAccountStatus("100011");
            try {
                adminService.update(naAdministratorUser);
            } catch (Exception e) {
                log.error(e.getMessage());
                return ResponseMessage.isSQLException();
            }

            return ResponseMessage.isSuccess("账号已经封存");
        }

        return ResponseMessage.isError("密码错误，请确认是否输入正确");
    }


    /**
     * @param @param []
     * @return @return java.util.Map
     * @throws
     * @Title: getLogin
     * @Description: TODO(登陆接口)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/9 12:06
     */
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    public Map<String, Object> getLogin(@RequestBody Map<String, String> param) {
        // 进行密码解密，然后MD5加密后和数据库对比，如果正确，则进行确认
        Map<String, String> result = new HashMap<>();
        NaUserToken userToken = new NaUserToken();
        String passWord = param.get("passWord");
        NaAdministratorUser admin = new NaAdministratorUser();
        admin.setUserPhone(param.get("userName"));
        try {
            admin = adminService.queryById(admin);
            if (admin == null) {
                return ResponseMessage.isError("用户不存在，请检查输入的用户名是否正确");
            }
            if ("100011".equals(admin.getAccountStatus())) {
                return ResponseMessage.isError("用户已注销，请联系超级管理员");
            }
            NaSecret naSecret = naSecretService.queryById(admin.getUserPhone());
            log.info("对密码进行RSA解密");
            passWord = RSAUtils.privateDecrypt(passWord, RSAUtils.getPrivateKey(naSecret.getAccountPrivateKey()));
//            log.info("------------------------------------------------------------------------");
//            log.info("解密后密文为：" + passWord);
//            log.info("------------------------------------------------------------------------");
            log.info("进行密码MD5加盐加密处理");
            passWord = UtilMethod.md5Encryption(passWord);
            log.info("进行账号密码查询，验证是否一致");
            if (admin.getUserPassword().equals(passWord)) {
                log.info("密码验证通过,进行token信息查询");
                userToken.setUserPhone(admin.getUserPhone());
                userToken.setToken(UtilMethod.getUuid());
                log.info("获取token：" + userToken.getToken());
                userToken.setTokenTime(UtilMethod.unixLong());
                log.info("token获取时间为：" + UtilMethod.unixToTime(userToken.getTokenTime(), ConstantParam.PATAM_DATE_TIME_FORMAT));
                NaUserToken naUserToken = naUserTokenService.queryById(admin.getUserPhone());
                if (naUserToken == null) {
                    log.info("初次登陆，生成token，并对数据库进行更新");
                    userToken = naUserTokenService.insert(userToken);
                } else {
                    log.info("非初次登陆，进行token以及时间更新");
                    naUserTokenService.update(userToken);
                }
                result.put("userToken", userToken.getToken());
                result.put("userPhone", userToken.getUserPhone());
                result.put("accountStatus", admin.getAccountStatus());
                result.put("userName", admin.getUserName());
                return ResponseMessage.isSuccess(result, "登陆成功，返回token");
            } else {
                log.info("密码验证失败");
                // 验证失败，返回失败信息
                return ResponseMessage.isError("密码验证失败");
            }
        } catch (Exception e) {
            log.error("获取私钥对象错误：" + e.getMessage());
            return ResponseMessage.isError("解密数据异常，检查加密参数是否正确");
        }
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: insertStudent
     * @Description: TODO(学生信息录入)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/10 20:19
     */
    @RequestMapping(value = "/entry", method = RequestMethod.POST)
    public Map insertStudent(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaStudentInformation student = new NaStudentInformation();
        log.info("获取最大学号");
        Map<String, String> map = naStudentInformationService.queryMaxNumber(paraMap.get("semesterNumber") + "%");
        log.info("计算学号");
        if ("0".equals(map.get("number"))) {
            log.info("恭喜你" + paraMap.get("studentName") + ",你是这一期第一位入学的同学,将会拿到身份象征的0001尾号的学号^v^");
            student.setStudentNumber(paraMap.get("semesterNumber") + "0001");
        } else {
            student.setStudentNumber(UtilMethod.getNumberMax(map.get("number")));
        }
        // 获取必要参数 -- 学生基本信息
        log.info("进行数据转换，准备数据插入");
        // 学期
        student.setSemesterNumber(paraMap.get("semesterNumber"));
        // 学生姓名
        student.setStudentName(paraMap.get("studentName"));
        // 年龄
        student.setAge(Integer.valueOf(paraMap.get("age")));
        // 性别
        student.setGenderNumber(paraMap.get("genderNumber"));
        // 学生手机号
        student.setPhone(paraMap.get("phone"));
        // 学历
        student.setEducationNumber(paraMap.get("educationNumber"));
        // 前职业
        student.setPreVocational(paraMap.get("preVocational"));
        // 家庭住址
        student.setHomeAddress(paraMap.get("homeAddress"));
        // 入学类型
        student.setAdmissionNumber(paraMap.get("admissionNumber"));
        // 备注信息
        student.setRemarks(paraMap.get("remarks"));
        // 介绍人
        student.setIntroducer(paraMap.get("introducer"));
        // 身份证
        student.setIdentityNumber(paraMap.get("identityNumber"));
        // 报名日期
        student.setRegistrationDate(Long.valueOf(paraMap.get("registrationDate")));
        // 宿舍编号
        student.setDormitoryNumber(paraMap.get("dormitoryNumber"));
        // 创建人
        student.setFounder(paraMap.get("userName"));
        // 创建时间
        student.setFounderTime(UtilMethod.unixLong());
        NaEmergencyContactInformation contactInf = new NaEmergencyContactInformation();
        // 紧急联系人姓名
        contactInf.setEmergencyContactName(paraMap.get("emergencyContactName"));
        // 紧急联系人ID
        contactInf.setEmergencyContactNumber(UtilMethod.getUnidNumber());
        //紧急联系人电话
        contactInf.setEmergencyContactPhone(paraMap.get("emergencyContactPhone"));
        // 紧急联系人关系ID
        contactInf.setEmergencyContactRelationshipNumber(paraMap.get("emergencyContactRelationshipNumber"));
        // 对学生信息进行紧急联系人关联
        student.setEmergencyContactNumber(contactInf.getEmergencyContactNumber());
        //更新数据的管理员信息
        contactInf.setFounder(paraMap.get("userName"));
        contactInf.setFounderTime(UtilMethod.unixLong());
        // 准备学生学费数据
        NaTuition naTuition = new NaTuition();
        // 关联学号
        naTuition.setStudentNumber(student.getStudentNumber());
        // 总费用
        naTuition.setTuitionNumber(paraMap.get("tuitionNumber"));
        // 优惠信息
        naTuition.setDiscountInfNumber(paraMap.get("discountInfNumber"));
        // 报名费
        naTuition.setRegisteryFee(Double.valueOf((paraMap.get("registeryFee"))));
        // 已缴费用
        naTuition.setTuitionPaid(Double.valueOf(paraMap.get("tuitionPaid")));
        // 剩余费用
        naTuition.setSurplusTuition(Double.valueOf(paraMap.get("surplusTuition")));
        // 管理员信息
        naTuition.setFounder(paraMap.get("userName"));
        naTuition.setFounderTime(UtilMethod.unixLong());
        // 对宿舍进行更新
        NaDormitoryInformation dormitory = new NaDormitoryInformation();
        dormitory.setDormitoryNumber(student.getDormitoryNumber());
        log.info("进行数据验证是否存在，避免重复脏数据");
        try {
            if (naStudentInformationService.queryByCount(student) > 0) {
                log.info("数据重复，不执行后续步骤，直接返回");
                return ResponseMessage.isError("学员信息已存在，请进行查询验证");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("对宿舍信息进行查询，确认可入住");
        try {
            if (!"-1".equals(student.getDormitoryNumber())) {
                dormitory = naDormitoryInformationService.queryById(student.getDormitoryNumber());
            } else {
                log.info("此学生不住宿");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }

        if (!"-1".equals(paraMap.get("dormitoryNumber"))) {
            if (dormitory.getRemainingBed() > 0) {
                dormitory.setRemainingBed(dormitory.getRemainingBed() - 1);

            } else {
                return ResponseMessage.isError("宿舍已满员，请重新选择");
            }
            if (!paraMap.get("genderNumber").equals(dormitory.getDormitoryProperty())) {
                return ResponseMessage.isError("不可将" + (Integer.valueOf(paraMap.get("genderNumber")) > Integer.valueOf(dormitory.getDormitoryProperty()) ? "男" : "女") + "生分配至" + (Integer.valueOf(paraMap.get("genderNumber")) > Integer.valueOf(dormitory.getDormitoryProperty()) ? "女" : "男") + "生宿舍");
            }
        }

        try {
            log.info("进行学生信息新增");
            naStudentInformationService.insert(student);
        } catch (Exception e) {
            // 进行数据回退
            log.info("数据新增失败");
            log.info(e.getMessage());
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        try {
            log.info("对学生紧急联系人进行更新");
            naEmergencyContactInformationService.insert(contactInf);

        } catch (Exception e) {
            log.info("紧急联系人更新失败，进行数据回退");
            naStudentInformationService.deleteById(student.getStudentNumber());
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        try {
            naTuitionService.insert(naTuition);
            log.info("收费信息更新完成");
        } catch (Exception e) {
            log.info("费用信息，进行学生数据回退");
            naStudentInformationService.deleteById(student.getStudentNumber());
            naEmergencyContactInformationService.deleteById(contactInf.getEmergencyContactNumber());
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        try {
            if (!"-1".equals(paraMap.get("dormitoryNumber"))) {
                log.info("进行宿舍信息更新");
                naDormitoryInformationService.update(dormitory);
            }
        } catch (Exception e) {
            log.info("宿舍信息新增失败，进行学生数据回退");
            naTuitionService.deleteById(naTuition.getStudentNumber());
            naStudentInformationService.deleteById(student.getStudentNumber());
            naEmergencyContactInformationService.deleteById(contactInf.getEmergencyContactNumber());
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }

        return ResponseMessage.isSuccess("学生信息新增成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getStudentAll
     * @Description: TODO(查询全部学生信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/17 19:59
     */
    @RequestMapping(value = "/queryStu", method = RequestMethod.POST)
    public Map getStudentAll(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        List<NaStudentInformation> list;
        List<Map<String, Object>> resultList = new LinkedList<>();
        // 管理员
        Map<String, String> adminMap;
        // 学期
        Map<String, String> semesterMap;
        // 学历
        Map<String, String> educationMap;
        // 紧急联系人信息
        Map<String, Map<String, String>> emergencyInfMap;
        // 紧急联系人关系
        Map<String, String> contactRelationshipMap;
        // 入学类型
        Map<String, String> naAdmissionTypeMap;
        try {
            list = naStudentInformationService.queryAll(new NaStudentInformation());
            adminMap = adminService.queryUserMap();
            semesterMap = naSemesterTableService.queryNumberToName();
            educationMap = naEducationService.queryNumberToName();
            emergencyInfMap = naEmergencyContactInformationService.queryNumberToName();
            contactRelationshipMap = naEmergencyContactRelationshipService.queryNumberToName();
            naAdmissionTypeMap = naAdmissionTypeService.queryNumberToName();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }

        log.info("进行全部学生数据转换");
        for (NaStudentInformation parameter : list) {
            Map<String, Object> resultMap = new HashMap<>();
            //学号
            resultMap.put("studentNumber", parameter.getStudentNumber());
            //学期ID
            resultMap.put("semesterNumber", parameter.getSemesterNumber());
            //学期 翻译值
            resultMap.put("semesterName", semesterMap.get(parameter.getSemesterNumber()));
            //姓名
            resultMap.put("studentName", parameter.getStudentName());
            //年龄
            resultMap.put("age", parameter.getAge());
            //性别
            resultMap.put("genderNumber", parameter.getGenderNumber());
            // 性别翻译值
            resultMap.put("sex", (parameter.getGenderNumber().equals("1") ? "男" : "女"));
            // phone
            resultMap.put("phone", parameter.getPhone());
            //学历 ID
            resultMap.put("educationNumber", parameter.getEducationNumber());
            // 学历翻译值
            resultMap.put("academicName", educationMap.get(parameter.getEducationNumber()));
            //前职业
            resultMap.put("preVocational", parameter.getPreVocational());
            //家庭住址
            resultMap.put("homeAddress", parameter.getHomeAddress());
            // 紧急联系人ID
            resultMap.put("emergencyContactNumber", parameter.getEmergencyContactNumber());
            if (emergencyInfMap.get(parameter.getEmergencyContactNumber()) != null) {
                //紧急联系姓名
                resultMap.put("emergencyContactName", emergencyInfMap.get(parameter.getEmergencyContactNumber()).get("emergencyContactName"));
                //与紧急联系人关系ID
                resultMap.put("emergencyContactRelationshipNumber", emergencyInfMap.get(parameter.getEmergencyContactNumber()).get("emergencyContactRelationshipNumber"));
                //与紧急联系人关系翻译值
                resultMap.put("emergencyContactRelationship", contactRelationshipMap.get(emergencyInfMap.get(parameter.getEmergencyContactNumber()).get("emergencyContactRelationshipNumber")));
                //紧急联系人电话
                resultMap.put("emergencyContactPhone", emergencyInfMap.get(parameter.getEmergencyContactNumber()).get("emergencyContactPhone"));
            } else {
                //紧急联系姓名
                resultMap.put("emergencyContactName", "-");
                //与紧急联系人关系ID
                resultMap.put("emergencyContactRelationshipNumber", "-");
                //与紧急联系人关系翻译值
                resultMap.put("emergencyContactRelationship", "-");
                //紧急联系人电话
                resultMap.put("emergencyContactPhone", "-");
            }
            //入学类型
            resultMap.put("admissionNumber", parameter.getAdmissionNumber());
            // 入学类型翻译值
            resultMap.put("studentAdmissionType", naAdmissionTypeMap.get(parameter.getAdmissionNumber()));
            //介绍人
            resultMap.put("introducer", parameter.getIntroducer());
            //备注信息
            resultMap.put("remarks", parameter.getRemarks());
            //身份证号
            resultMap.put("identityNumber", parameter.getIdentityNumber());
            //报名日期
            resultMap.put("registrationDate", parameter.getRegistrationDate());
            //宿舍编号
            resultMap.put("dormitoryNumber", parameter.getDormitoryNumber().equals("-1") ? "-" : parameter.getDormitoryNumber());
            //创建人
            resultMap.put("founder", adminMap.get(parameter.getFounder()));
            //创建时间
            resultMap.put("founderTime", parameter.getFounderTime());
            //更新人
            resultMap.put("updater", adminMap.get(parameter.getUpdater()));
            //更新时间
            resultMap.put("updateTime", parameter.getUpdateTime());
            //数据增入list
            resultList.add(resultMap);
        }
        return ResponseMessage.isSuccess(resultList, "查询成功，返回全部学生数据");
    }

    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getStudentAll
     * @Description: TODO(根据学号查询学生信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/17 19:59
     */
    @RequestMapping(value = "/queryStuId", method = RequestMethod.POST)
    public Map getStudentNumber(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaStudentInformation naStudentInformation;
        // 管理员
        Map<String, String> adminMap;
        // 学期
        Map<String, String> semesterMap;
        // 学历
        Map<String, String> educationMap;
        // 紧急联系人信息
        Map<String, Map<String, String>> emergencyInfMap;
        // 紧急联系人关系
        Map<String, String> contactRelationshipMap;
        // 入学类型
        Map<String, String> naAdmissionTypeMap;
        // 费用信息
        Map<String, Map<String, Object>> tuitionMap;
        // 费用基准信息
        Map<String, String> tuitionFeeMap;
        // 优惠信息
        Map<String, Map<String, Object>> discountInfMap;
        try {
            naStudentInformation = naStudentInformationService.queryById(paraMap.get("studentNumber"));
            adminMap = adminService.queryUserMap();
            semesterMap = naSemesterTableService.queryNumberToName();
            educationMap = naEducationService.queryNumberToName();
            emergencyInfMap = naEmergencyContactInformationService.queryNumberToName();
            contactRelationshipMap = naEmergencyContactRelationshipService.queryNumberToName();
            naAdmissionTypeMap = naAdmissionTypeService.queryNumberToName();
            tuitionMap = naTuitionService.queryNumberToName();
            tuitionFeeMap = naTuitionFeeScheduleService.queryTuitionFeeInf();
            discountInfMap = naDiscountInformationService.queryDiscInf();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("进行全部学生数据转换");
        Map<String, Object> resultMap = new HashMap<>();
        //学号
        resultMap.put("studentNumber", naStudentInformation.getStudentNumber());
        //学期ID
        resultMap.put("semesterNumber", naStudentInformation.getSemesterNumber());
        //学期 翻译值
        resultMap.put("semesterName", semesterMap.get(naStudentInformation.getSemesterNumber()));
        //姓名
        resultMap.put("studentName", naStudentInformation.getStudentName());
        //年龄
        resultMap.put("age", naStudentInformation.getAge());
        //性别
        resultMap.put("genderNumber", naStudentInformation.getGenderNumber());
        // 性别翻译值
        resultMap.put("sex", (naStudentInformation.getGenderNumber().equals("1") ? "男" : "女"));
        // phone
        resultMap.put("phone", naStudentInformation.getPhone());
        //学历 ID
        resultMap.put("educationNumber", naStudentInformation.getEducationNumber());
        // 学历翻译值
        resultMap.put("academicName", educationMap.get(naStudentInformation.getEducationNumber()));
        //前职业
        resultMap.put("preVocational", naStudentInformation.getPreVocational());
        //家庭住址
        resultMap.put("homeAddress", naStudentInformation.getHomeAddress());
        // 紧急联系人ID
        resultMap.put("emergencyContactNumber", naStudentInformation.getEmergencyContactNumber());
        //紧急联系姓名
        resultMap.put("emergencyContactName", emergencyInfMap.get(naStudentInformation.getEmergencyContactNumber()).get("emergencyContactName"));
        //与紧急联系人关系ID
        resultMap.put("emergencyContactRelationshipNumber", emergencyInfMap.get(naStudentInformation.getEmergencyContactNumber()).get("emergencyContactRelationshipNumber"));
        //与紧急联系人关系翻译值
        resultMap.put("emergencyContactRelationship", contactRelationshipMap.get(emergencyInfMap.get(naStudentInformation.getEmergencyContactNumber()).get("emergencyContactRelationshipNumber")));
        //紧急联系人电话
        resultMap.put("emergencyContactPhone", emergencyInfMap.get(naStudentInformation.getEmergencyContactNumber()).get("emergencyContactPhone"));
        //入学类型
        resultMap.put("admissionNumber", naStudentInformation.getAdmissionNumber());
        // 入学类型翻译值
        resultMap.put("studentAdmissionType", naAdmissionTypeMap.get(naStudentInformation.getAdmissionNumber()));
        // 总费用ID
        resultMap.put("tuitionNumber", tuitionMap.get(naStudentInformation.getStudentNumber()).get("tuitionNumber"));
        // 总费用金额
        resultMap.put("tuitionAmount", tuitionFeeMap.get(String.valueOf(tuitionMap.get(naStudentInformation.getStudentNumber()).get("tuitionNumber"))));
        // 优惠信息ID
        resultMap.put("discountInfNumber", tuitionMap.get(naStudentInformation.getStudentNumber()).get("discountInfNumber"));
        // 优惠信息名称
        resultMap.put("discountInfName", discountInfMap.get(String.valueOf(tuitionMap.get(naStudentInformation.getStudentNumber()).get("discountInfNumber"))).get("discountInfName"));
        // 优惠金额
        resultMap.put("discountAmount", discountInfMap.get(String.valueOf(tuitionMap.get(naStudentInformation.getStudentNumber()).get("discountInfNumber"))).get("discountAmount"));
        // 报名费
        resultMap.put("registeryFee", tuitionMap.get(naStudentInformation.getStudentNumber()).get("registeryFee"));
        // 已缴费用
        resultMap.put("tuitionPaid", tuitionMap.get(naStudentInformation.getStudentNumber()).get("tuitionPaid"));
        // 剩余费用
        resultMap.put("surplusTuition", tuitionMap.get(naStudentInformation.getStudentNumber()).get("surplusTuition"));
        //介绍人
        resultMap.put("introducer", naStudentInformation.getIntroducer());
        //备注信息
        resultMap.put("remarks", naStudentInformation.getRemarks());
        //身份证号
        resultMap.put("identityNumber", naStudentInformation.getIdentityNumber());
        //报名日期
        resultMap.put("registrationDate", naStudentInformation.getRegistrationDate());
        //宿舍编号
        resultMap.put("dormitoryNumber", naStudentInformation.getDormitoryNumber().equals("-1") ? "-" : naStudentInformation.getDormitoryNumber());
        //创建人
        resultMap.put("founder", adminMap.get(naStudentInformation.getFounder()));
        //创建时间
        resultMap.put("founderTime", naStudentInformation.getFounderTime());
        //更新人
        resultMap.put("updater", adminMap.get(naStudentInformation.getUpdater()));
        //更新时间
        resultMap.put("updateTime", naStudentInformation.getUpdateTime());
        return ResponseMessage.isSuccess(resultMap, "查询成功，返回全部学生数据");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: updateStudent
     * @Description: TODO(修改学生信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/18 11:57
     */
    @RequestMapping(value = "/updateStu", method = RequestMethod.POST)
    public Map updateStudent(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaStudentInformation student = new NaStudentInformation();
        // 获取必要参数 -- 学生基本信息
        log.info("进行数据转换，准备数据修改");
        // 学期
        student.setSemesterNumber(paraMap.get("semester"));
        // 学号
        student.setStudentNumber(paraMap.get("studentNumber"));
        // 学生姓名
        student.setStudentName(paraMap.get("studentName"));
        // 年龄
        student.setAge(Integer.valueOf(paraMap.get("age")));
        // 性别
        student.setGenderNumber(paraMap.get("genderNumber"));
        // 学生手机号
        student.setPhone(paraMap.get("phone"));
        // 学历
        student.setEducationNumber(paraMap.get("educationNumber"));
        // 前职业
        student.setPreVocational(paraMap.get("preVocational"));
        // 家庭住址
        student.setHomeAddress(paraMap.get("homeAddress"));
        // 入学类型
        student.setAdmissionNumber(paraMap.get("admissionNumber"));
        // 备注信息
        student.setRemarks(paraMap.get("remarks"));
        // 介绍人
        student.setIntroducer(paraMap.get("introducer"));
        // 身份证
        student.setIdentityNumber(paraMap.get("identityNumber"));
        // 报名日期
        student.setRegistrationDate(Long.valueOf(paraMap.get("registrationDate")));
        // 宿舍编号
        student.setDormitoryNumber(paraMap.get("dormitoryNumber"));
        // 创建人
        student.setUpdater(paraMap.get("userName"));
        // 创建时间
        student.setUpdateTime(UtilMethod.unixLong());
        NaEmergencyContactInformation contactInf = new NaEmergencyContactInformation();
        // 紧急联系人姓名
        contactInf.setEmergencyContactName(paraMap.get("emergencyContactName"));
        // 紧急联系人ID
        contactInf.setEmergencyContactNumber(paraMap.get("emergencyContactNumber"));
        //紧急联系人电话
        contactInf.setEmergencyContactPhone(paraMap.get("emergencyContactPhone"));
        // 紧急联系人关系ID
        contactInf.setEmergencyContactRelationshipNumber(paraMap.get("emergencyContactRelationshipNumber"));
        // 对学生信息进行紧急联系人关联
        student.setEmergencyContactNumber(contactInf.getEmergencyContactNumber());
        //更新数据的管理员信息
        contactInf.setFounder(paraMap.get("userName"));
        contactInf.setFounderTime(UtilMethod.unixLong());
        // 准备学生学费数据
        NaTuition naTuition = new NaTuition();
        // 关联学号
        naTuition.setStudentNumber(student.getStudentNumber());
        // 总费用
        naTuition.setTuitionNumber(paraMap.get("tuitionNumber"));
        // 优惠信息
        naTuition.setDiscountInfNumber(paraMap.get("discountInfNumber"));
        // 报名费
        naTuition.setRegisteryFee(Double.valueOf((paraMap.get("registeryFee"))));
        // 已缴费用
        naTuition.setTuitionPaid(Double.valueOf(paraMap.get("tuitionPaid")));
        // 剩余费用
        naTuition.setSurplusTuition(Double.valueOf(paraMap.get("surplusTuition")));
        // 管理员信息
        naTuition.setUpdater(paraMap.get("userName"));
        naTuition.setUpdateTime(UtilMethod.unixLong());
        // 对宿舍进行更新
        NaDormitoryInformation dormitory = new NaDormitoryInformation();
        dormitory.setDormitoryNumber(student.getDormitoryNumber());
        log.info("对宿舍信息进行查询，确认可入住");
        try {
            if (!"-1".equals(paraMap.get("dormitoryNumber"))) {
                dormitory = naDormitoryInformationService.queryById(student.getDormitoryNumber());
            } else {
                log.info("此学生搬离宿舍");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        if (!"-1".equals(paraMap.get("dormitoryNumber"))) {
            if (dormitory.getRemainingBed() > 0) {
                dormitory.setRemainingBed(dormitory.getRemainingBed() - 1);
            } else {
                return ResponseMessage.isError("宿舍已满员，请重新选择");
            }
        }
        log.info("对旧宿舍进行恢复床位");
        NaStudentInformation naStudentInformation;
        NaDormitoryInformation naDormitoryInformation = new NaDormitoryInformation();
        try {
            naStudentInformation = naStudentInformationService.queryById(student.getStudentNumber());
            // 对历史宿舍信息进行查询
            if (!"-1".equals(naStudentInformation.getDormitoryNumber())){
                naDormitoryInformation = naDormitoryInformationService.queryById(naStudentInformation.getDormitoryNumber());
                // 进行历史宿舍的信息更新回填
                naDormitoryInformation.setRemainingBed(naDormitoryInformation.getRemainingBed() + 1);
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        if (!"-1".equals(paraMap.get("dormitoryNumber"))){
            if (!paraMap.get("genderNumber").equals(dormitory.getDormitoryProperty())) {
                return ResponseMessage.isError("不可将" + (Integer.valueOf(paraMap.get("genderNumber")) > Integer.valueOf(dormitory.getDormitoryProperty()) ? "男" : "女") + "生分配至" + (Integer.valueOf(paraMap.get("genderNumber")) > Integer.valueOf(dormitory.getDormitoryProperty()) ? "女" : "男") + "生宿舍");
            }
        }
        try {
            log.info("进行学生信息新增");
            naStudentInformationService.update(student);
            log.info("对学生紧急联系人进行更新");
            naEmergencyContactInformationService.update(contactInf);
            log.info("开始更新收费信息更新");
            naTuitionService.update(naTuition);
            if (!paraMap.get("dormitoryNumber").equals(String.valueOf(naDormitoryInformation.getRemainingBed()))) {
                if (!"-1".equals(paraMap.get("dormitoryNumber"))) {
                    log.info("进行新宿舍信息更新");
                    naDormitoryInformationService.update(dormitory);
                }
                // 如之前未住宿，则不进行历史更新
                if (!"-1".equals(naStudentInformation.getDormitoryNumber())) {
                    log.info("对旧宿舍进行信息更新");
                    naDormitoryInformationService.update(naDormitoryInformation);
                }
            } else {
                log.info("宿舍没有发生变化，不进行更新");
            }
        } catch (Exception e) {
            // 进行数据回退
            log.info("数据更新失败");
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();

        }
        return ResponseMessage.isSuccess("数据更新成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getSemester
     * @Description: TODO(查询全部学期信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/11 9:50
     */
    @RequestMapping(value = "/querySem", method = RequestMethod.POST)
    public Map getSemester(@RequestBody Map<String, String> paraMap) {
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        log.info("token验证成功，进行学期信息查询");
        NaSemesterTable naSemesterTable = new NaSemesterTable();
        List<NaSemesterTable> resultList;
        try {
            resultList = naSemesterTableService.queryAll(naSemesterTable);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        Map<String, String> adminMap;
        try {
            adminMap = adminService.queryUserMap();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("进行管理员数据Id--->name的转换");
        for (NaSemesterTable parameter : resultList) {
            parameter.setFounder(adminMap.get(parameter.getFounder()));
            parameter.setUpdater(adminMap.get(parameter.getUpdater()));
        }
        return ResponseMessage.isSuccess(resultList, "查询所有学期信息成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getAddSemester
     * @Description: TODO(学期信息新增)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/11 10:42
     */
    @RequestMapping(value = "/addSem", method = RequestMethod.POST)
    public Map getAddSemester(@RequestBody Map<String, String> paraMap) {
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaSemesterTable naSemesterTable = new NaSemesterTable();
        log.info("生成学期编号,编号为：PGY+开学日期");
        naSemesterTable.setSemesterNumber("PGY"
                + UtilMethod.unixToTime(Long.valueOf(paraMap.get("startDate")), ConstantParam.PATAM_DATE_PLAIN_FORMAT));
        naSemesterTable.setSemesterName(paraMap.get("semesterName"));
        naSemesterTable.setStartDate(Long.valueOf(paraMap.get("startDate")));
        naSemesterTable.setFounder(paraMap.get("userName"));
        log.info("获取当前时间戳，进行创建时间生成");
        naSemesterTable.setFounderTime(UtilMethod.unixLong());
        try {
            log.info(naSemesterTable.getSemesterName());
            log.info(String.valueOf(naSemesterTableService.queryAllByName(naSemesterTable.getSemesterName())));
            if ((naSemesterTableService.queryAllByName(naSemesterTable.getSemesterName())).isEmpty()) {
                naSemesterTableService.insert(naSemesterTable);
            } else {
                return ResponseMessage.isError("学期信息已经存在，请检查是否输入正确");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }

        return ResponseMessage.isSuccess("学期信息更新成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: addContact
     * @Description: TODO(联系人关系信息新增)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/11 21:14
     */
    @RequestMapping(value = "/addEgcrs", method = RequestMethod.POST)
    public Map insertContact(@RequestBody Map<String, String> paraMap) {
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        log.info("进行关系检查");
        if (naEmergencyContactRelationshipService.queryAllByName(paraMap.get("emergencyContactRelationship")).size() > 0) {
            return ResponseMessage.isError("联系人关系已存在");
        }
        log.info("进行联系人关系新增");
        NaEmergencyContactRelationship emergency = new NaEmergencyContactRelationship();
        log.info("获取到紧急联系人关系名称");
        emergency.setEmergencyContactRelationship(paraMap.get("emergencyContactRelationship"));
        log.info("进行ID生成，并进行创建人和创建时间获取");
        emergency.setEmergencyContactRelationshipNumber(UtilMethod.getUnidNumber());
        emergency.setFounder(paraMap.get("userName"));
        emergency.setFounderTime(UtilMethod.unixLong());
        try {
            naEmergencyContactRelationshipService.insert(emergency);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("联系人关系新增成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map<java.lang.String,java.lang.String>
     * @throws
     * @Title: getEncrs
     * @Description: TODO(联系人关系信息查询)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/12 16:37
     */
    @RequestMapping(value = "/queryEgcrs", method = RequestMethod.POST)
    public Map getEncrs(@RequestBody Map<String, String> paraMap) {
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        log.info("进行全部信息查询");
        List<NaEmergencyContactRelationship> resultList;
        Map<String, String> adminMap;
        try {
            resultList = naEmergencyContactRelationshipService.queryAll(new NaEmergencyContactRelationship());
            adminMap = adminService.queryUserMap();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }

        log.info("进行管理员数据Id--->name的转换");
        for (NaEmergencyContactRelationship parameter : resultList) {
            parameter.setFounder(adminMap.get(parameter.getFounder()));
            parameter.setUpdater(adminMap.get(parameter.getUpdater()));
        }
        return ResponseMessage.isSuccess(resultList, "查询所有联系人关系成功");
    }


    /**
     * @param @param [pataMap]
     * @return @return java.util.Map
     * @throws
     * @Title: addAdmissionType
     * @Description: TODO(学历信息新增)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/12 17:08
     */
    @RequestMapping(value = "/addEducation", method = RequestMethod.POST)
    public Map insertAcademicInformation(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        log.info("进行数据检查，是否重复");
        NaEducation naEducation = new NaEducation();
        try {
            naEducationService.queryAllByName(paraMap.get("academicName"));
            if (naEducationService.queryAllByName(paraMap.get("academicName")).size() > 0) {
                return ResponseMessage.isError("学历信息已存在");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("生成学历编号以及对创建人创建时间新增");
        naEducation.setEducationNumber(UtilMethod.getUnidNumber());
        naEducation.setAcademicName(paraMap.get("academicName"));
        naEducation.setFounder(paraMap.get("userName"));
        naEducation.setFounderTime(UtilMethod.unixLong());
        try {
            naEducationService.insert(naEducation);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("学历信息入库成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getAcademicInformation
     * @Description: TODO(全部学历信息查询)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/12 17:48
     */
    @RequestMapping(value = "/queryEducation", method = RequestMethod.POST)
    public Map getAcademicInformation(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        List<NaEducation> resultList;
        Map<String, String> adminMap;
        try {
            resultList = naEducationService.queryAll(new NaEducation());
            adminMap = adminService.queryUserMap();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("进行管理员数据Id--->name的转换");
        for (NaEducation parameter : resultList) {
            parameter.setFounder(adminMap.get(parameter.getFounder()));
            parameter.setUpdater(adminMap.get(parameter.getUpdater()));
        }
        return ResponseMessage.isSuccess(resultList, "学历信息查询成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: addAdmissionType
     * @Description: TODO(新增入学类型信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/12 18:06
     */
    @RequestMapping(value = "/addAdmType", method = RequestMethod.POST)
    public Map insertAdmissionType(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        log.info("进行数据核查，是否会重复");
        if (naAdmissionTypeService.queryAllByName(paraMap.get("studentAdmissionType")).size() > 0) {
            return ResponseMessage.isError("入学类型");
        }
        log.info("进行数据入库");
        NaAdmissionType naAdmissionType = new NaAdmissionType();
        naAdmissionType.setAdmissionNumber(UtilMethod.getUnidNumber());
        naAdmissionType.setStudentAdmissionType(paraMap.get("studentAdmissionType"));
        naAdmissionType.setFounder(paraMap.get("userName"));
        naAdmissionType.setFounderTime(UtilMethod.unixLong());
        naAdmissionTypeService.insert(naAdmissionType);
        return ResponseMessage.isSuccess("入学类型库如成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getAdmissionType
     * @Description: TODO(全部入学类型信息查询)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/12 18:29
     */
    @RequestMapping(value = "/queryAdmType", method = RequestMethod.POST)
    public Map getAdmissionType(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        List<NaAdmissionType> resultList;
        try {
            resultList = naAdmissionTypeService.queryAll(new NaAdmissionType());
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        Map<String, String> adminMap = adminService.queryUserMap();
        log.info("进行管理员数据Id--->name的转换");
        for (NaAdmissionType parameter : resultList) {
            parameter.setFounder(adminMap.get(parameter.getFounder()));
            parameter.setUpdater(adminMap.get(parameter.getUpdater()));
        }
        return ResponseMessage.isSuccess(resultList, "查询全部数据成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: addDormitoryInformation
     * @Description: TODO(新增宿舍信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/12 20:09
     */
    @RequestMapping(value = "/addDorm", method = RequestMethod.POST)
    public Map addDormitoryInformation(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        try {
            if (naDormitoryInformationService.queryAllCount(paraMap.get("dormitoryNumber")) > 0) {
                return ResponseMessage.isError("宿舍信息重复，入库失败");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("进行宿舍数据入库");
        NaDormitoryInformation dormitory = new NaDormitoryInformation();
        dormitory.setDormitoryNumber(paraMap.get("dormitoryNumber"));
        dormitory.setFounder(paraMap.get("userName"));
        dormitory.setFounderTime(UtilMethod.unixLong());
        dormitory.setRemainingBed(Integer.valueOf(paraMap.get("totalBed")));
        dormitory.setTotalBed(Integer.valueOf(paraMap.get("totalBed")));
        dormitory.setDormitoryProperty(paraMap.get("dormitoryProperty"));
        dormitory.setRoomPassword(paraMap.get("roomPassword"));
        try {
            naDormitoryInformationService.insert(dormitory);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("宿舍信息入库成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getDormitoryNumber
     * @Description: TODO(根据宿舍编号查询宿舍信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/13 13:42
     */
    @RequestMapping(value = "/queryDormId", method = RequestMethod.POST)
    public Map getDormitoryNumber(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        Map<String, String> adminMap;
        NaDormitoryInformation dormitory;
        try {
            adminMap = adminService.queryUserMap();
            dormitory = naDormitoryInformationService.queryById(paraMap.get("dormitoryNumber"));
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        dormitory.setDormitoryProperty(dormitory.getDormitoryProperty().equals("1") ? "男" : "女");
        dormitory.setFounder(adminMap.get(dormitory.getFounder()));
        dormitory.setUpdater(adminMap.get(dormitory.getUpdater()));
        return ResponseMessage.isSuccess(dormitory, "查询成功返回宿舍信息");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getDormitory
     * @Description: TODO(查询全部宿舍信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/13 14:05
     */
    @RequestMapping(value = "queryDorm", method = RequestMethod.POST)
    public Map getDormitory(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        List<NaDormitoryInformation> resultList;
        Map<String, String> adminMap;
        try {
            resultList = naDormitoryInformationService.queryAll(new NaDormitoryInformation());
            adminMap = adminService.queryUserMap();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("进行管理员数据Id--->name的转换");
        for (NaDormitoryInformation parameter : resultList) {
            parameter.setDormitoryProperty(parameter.getDormitoryProperty().equals("1") ? "男" : "女");
            parameter.setFounder(adminMap.get(parameter.getFounder()));
            parameter.setUpdater(adminMap.get(parameter.getUpdater()));
        }
        return ResponseMessage.isSuccess(resultList, "查询全部数据成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: updateDormitory
     * @Description: TODO(修改宿舍信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/13 14:58
     */
    @RequestMapping(value = "/updateDorm", method = RequestMethod.POST)
    public Map updateDormitory(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaDormitoryInformation dormitory = new NaDormitoryInformation();
        dormitory.setTotalBed(Integer.valueOf(paraMap.get("totalBed")));
        dormitory.setUpdater(paraMap.get("userName"));
        dormitory.setUpdateTime(UtilMethod.unixLong());
        dormitory.setDormitoryNumber(paraMap.get("dormitoryNumber"));
        dormitory.setRoomPassword(paraMap.get("roomPassword"));
        dormitory.setRemainingBed(Integer.valueOf(paraMap.get("remainingBed")));
        dormitory.setDormitoryProperty(paraMap.get("dormitoryProperty"));
        try {
            naDormitoryInformationService.update(dormitory);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("宿舍信息修改成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: deleteDormitory
     * @Description: TODO(删除宿舍信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/13 15:16
     */
    @RequestMapping(value = "/delDorm", method = RequestMethod.POST)
    public Map deleteDormitory(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        try {
            if (naDormitoryInformationService.queryAllCount(paraMap.get("dormitoryNumber")) < 1) {
                return ResponseMessage.isError("宿舍信息不存在，删除失败");
            }
            log.info("进行学生住宿信息查询");
            // 以防止出现学生住宿，宿舍不存在的脏数据
            NaStudentInformation naStudentInformation = new NaStudentInformation();
            naStudentInformation.setDormitoryNumber(paraMap.get("dormitoryNumber"));
            List<NaStudentInformation> resultList = naStudentInformationService.queryAll(naStudentInformation);
            log.info("进行次宿舍的学生信息拼接");
            StringBuilder sd = new StringBuilder();
            sd.append("以下学员已入住");
            sd.append(paraMap.get("dormitoryNumber"));
            sd.append(":\n");
            for (NaStudentInformation information : resultList) {
                sd.append(information.getStudentName());
                sd.append("\t");
            }
            sd.append("\n请先修改以上学员的宿舍信息为不住宿，在进行删除操作");
            if (resultList.size() > 0) {
                return ResponseMessage.isError(sd.toString());
            }
            if (naDormitoryInformationService.deleteById(paraMap.get("dormitoryNumber"))) {
                return ResponseMessage.isSuccess("宿舍信息删除成功");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isError("宿舍信息删除失败");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getTuition
     * @Description: TODO(单学生ID查询费用信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 9:01
     */
    @RequestMapping(value = "/queryTuition", method = RequestMethod.POST)
    public Map getTuition(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }

        // resultList用于接收最终参数
        NaTuition naTuition;
        //tuFeeList 用于接收NaTuitionFeeSchedule查询到的附参数
        Map<String, String> tuFeeMap;
        // discList 用户接收查询到的NaDiscountInformation的附属参数
        Map<String, Map<String, Object>> discMap;
        log.info("查询主参数表：NA_TUITION表数据");
        try {
            discMap = naDiscountInformationService.queryDiscInf();
            tuFeeMap = naTuitionFeeScheduleService.queryTuitionFeeInf();
            naTuition = naTuitionService.queryById(paraMap.get("studentNumber"));
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        if (naTuition == null){
            return ResponseMessage.isError("学生学号不存在");
        }
        log.info("进行返回参数生成");
        Map<String, Object> resultMap = new LinkedHashMap<>();
        resultMap.put("studentNumber", naTuition.getStudentNumber());
        resultMap.put("discountInfNumber", naTuition.getDiscountInfNumber());
        resultMap.put("discountInfName", discMap.get(naTuition.getDiscountInfNumber()).get("discountInfName"));
        resultMap.put("discountAmount", discMap.get(naTuition.getDiscountInfNumber()).get("discountAmount"));
        resultMap.put("registeryFee", naTuition.getRegisteryFee());
        resultMap.put("tuitionPaid", naTuition.getTuitionPaid());
        resultMap.put("surplusTuition", naTuition.getSurplusTuition());
        resultMap.put("tuitionNumber", naTuition.getTuitionNumber());
        resultMap.put("tuitionAmount", Double.valueOf(tuFeeMap.get(naTuition.getTuitionNumber())));
        resultMap.put("founder", naTuition.getFounder());
        resultMap.put("founderTime", naTuition.getFounderTime());
        resultMap.put("updater", naTuition.getUpdater());
        resultMap.put("updateTime", naTuition.getUpdateTime());
        return ResponseMessage.isSuccess(resultMap, "查询成功，返回学费详细信息");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: updateTuition
     * @Description: TODO(修改学费信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 15:05
     */
    @RequestMapping(value = "/updateTuition", method = RequestMethod.POST)
    public Map updateTui(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaTuition naTuition = new NaTuition();
        naTuition.setStudentNumber(paraMap.get("studentNumber"));
        naTuition.setDiscountInfNumber(paraMap.get("discountInfNumber"));
        naTuition.setTuitionNumber(paraMap.get("tuitionInfNumber"));
        naTuition.setRegisteryFee(Double.valueOf(paraMap.get("registeryFee")));
        naTuition.setSurplusTuition(Double.valueOf(paraMap.get("surplusTuition")));
        naTuition.setTuitionPaid(Double.valueOf(paraMap.get("tuitionPaid")));
        naTuition.setUpdater(paraMap.get("userName"));
        naTuition.setUpdateTime(UtilMethod.unixLong());
        try {
            naTuitionService.update(naTuition);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("学费信息更新成功");
    }


    /**
     * @param @param [pataMap]
     * @return @return java.util.Map
     * @throws
     * @Title: insertTuitionFeeSchedule
     * @Description: TODO(新增费用信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 16:59
     */
    @RequestMapping(value = "/addTui", method = RequestMethod.POST)
    public Map insertTuitionFeeSchedule(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaTuitionFeeSchedule naTuitionFeeSchedule = new NaTuitionFeeSchedule();
        naTuitionFeeSchedule.setTuitionInfNumber(UtilMethod.getUnidNumber());
        naTuitionFeeSchedule.setTuitionName(paraMap.get("stuTuitionName"));
        naTuitionFeeSchedule.setTuitionAmount(Double.valueOf(paraMap.get("stuTuitionAmount")));
        naTuitionFeeSchedule.setTuitionDescription(paraMap.get("tuitionDescription"));
        naTuitionFeeSchedule.setFounder(paraMap.get("userName"));
        naTuitionFeeSchedule.setFounderTime(UtilMethod.unixLong());
        try {
            naTuitionFeeScheduleService.insert(naTuitionFeeSchedule);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("学费信息新增成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: updateTuitionFeeSchedule
     * @Description: TODO(更新学费信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 17:29
     */
    @RequestMapping(value = "/updateTui", method = RequestMethod.POST)
    public Map updateTuitionFeeSchedule(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaTuitionFeeSchedule naTuitionFeeSchedule = new NaTuitionFeeSchedule();
        naTuitionFeeSchedule.setTuitionInfNumber(paraMap.get("tuitionInfNumber"));
        naTuitionFeeSchedule.setTuitionName(paraMap.get("stuTuitionName"));
        naTuitionFeeSchedule.setTuitionAmount(Double.valueOf(paraMap.get("stuTuitionAmount")));
        naTuitionFeeSchedule.setTuitionDescription(paraMap.get("tuitionDescription"));
        naTuitionFeeSchedule.setUpdater(paraMap.get("userName"));
        naTuitionFeeSchedule.setUpdateTime(UtilMethod.unixLong());
        try {
            naTuitionFeeScheduleService.update(naTuitionFeeSchedule);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("学费信息更新成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getTuitionFeeSchedule
     * @Description: TODO(查询全部学费信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 17:42
     */
    @RequestMapping(value = "/queryTui", method = RequestMethod.POST)
    public Map getTuitionFeeSchedule(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        List<NaTuitionFeeSchedule> resultList;
        Map<String, String> adminMap;
        try {
            resultList = naTuitionFeeScheduleService.queryAll(new NaTuitionFeeSchedule());
            adminMap = adminService.queryUserMap();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("进行管理员数据Id--->name的转换");
        for (NaTuitionFeeSchedule parameter : resultList) {
            parameter.setFounder(adminMap.get(parameter.getFounder()));
            parameter.setUpdater(adminMap.get(parameter.getUpdater()));
            parameter.setTuitionName(parameter.getTuitionName() + "(" + parameter.getTuitionAmount() + ")");
        }
        return ResponseMessage.isSuccess(resultList, "查询全部学费信息成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getTuitionFeeScheduleId
     * @Description: TODO(费用信息ID查询)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 17:48
     */
    @RequestMapping(value = "/queryTuiNumber", method = RequestMethod.POST)
    public Map getTuitionFeeScheduleId(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        Map<String, String> adminMap;
        NaTuitionFeeSchedule naTuitionFeeSchedule;
        try {
            adminMap = adminService.queryUserMap();
            naTuitionFeeSchedule = naTuitionFeeScheduleService.queryById(paraMap.get("tuitionInfNumber"));
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        naTuitionFeeSchedule.setFounder(adminMap.get(naTuitionFeeSchedule.getFounder()));
        naTuitionFeeSchedule.setUpdater(adminMap.get(naTuitionFeeSchedule.getUpdater()));
        return ResponseMessage.isSuccess(naTuitionFeeSchedule, paraMap.get("tuitionInfNumber") + "查询成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: insertDiscountInf
     * @Description: TODO(新增优惠信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 18:19
     */
    @RequestMapping(value = "/addDisc", method = RequestMethod.POST)
    public Map insertDiscountInf(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaDiscountInformation naDiscountInformation = new NaDiscountInformation();
        naDiscountInformation.setDiscountInfNumber(UtilMethod.getUnidNumber());
        naDiscountInformation.setDiscountInfName(paraMap.get("discountInfName"));
        naDiscountInformation.setDiscountAmount(Double.valueOf(paraMap.get("discountAmount")));
        naDiscountInformation.setDiscountDescription(paraMap.get("discountDescription"));
        naDiscountInformation.setFounder(paraMap.get("userName"));
        naDiscountInformation.setFounderTime(UtilMethod.unixLong());
        try {
            naDiscountInformationService.insert(naDiscountInformation);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("新增优惠信息成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getDiscountInf
     * @Description: TODO(查询所有优惠信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 19:37
     */
    @RequestMapping(value = "/queryDisc", method = RequestMethod.POST)
    public Map getDiscountInf(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        List<NaDiscountInformation> resultList;
        Map<String, String> adminMap;
        try {
            resultList = naDiscountInformationService.queryAll(new NaDiscountInformation());
            adminMap = adminService.queryUserMap();
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        log.info("进行管理员数据Id--->name的转换");
        for (NaDiscountInformation parameter : resultList) {
            parameter.setFounder(adminMap.get(parameter.getFounder()));
            parameter.setUpdater(adminMap.get(parameter.getUpdater()));
        }
        return ResponseMessage.isSuccess(resultList, "查询全部优惠信息成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: getDiscountInfId
     * @Description: TODO(查询单个优惠信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 19:49
     */
    @RequestMapping(value = "/queryDiscId", method = RequestMethod.POST)
    public Map getDiscountInfId(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        Map<String, String> adminMap;
        NaDiscountInformation naDiscountInformation;
        try {
            adminMap = adminService.queryUserMap();
            naDiscountInformation = naDiscountInformationService.queryById(paraMap.get("discountInfNumber"));
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        naDiscountInformation.setFounder(adminMap.get(naDiscountInformation.getFounder()));
        naDiscountInformation.setUpdater(adminMap.get(naDiscountInformation.getUpdater()));
        return ResponseMessage.isSuccess(naDiscountInformation, paraMap.get("discountInfNumber") + "查询成功");
    }


    /**
     * @param @param [paraMap]
     * @return @return java.util.Map
     * @throws
     * @Title: updatetDiscountInfId
     * @Description: TODO(修改优惠信息)
     * @author sunbo@pgytesting.cn
     * @date 2019/4/15 19:54
     */
    @RequestMapping(value = "/updateDisc", method = RequestMethod.POST)
    public Map updateDiscountInfId(@RequestBody Map<String, String> paraMap) {
        // token验证
        if (naUserTokenService.tokenVerification(paraMap)) {
            return ResponseMessage.isCookieError();
        }
        NaDiscountInformation naDiscountInformation = new NaDiscountInformation();
        naDiscountInformation.setDiscountInfNumber(paraMap.get("discountInfNumber"));
        naDiscountInformation.setDiscountInfName(paraMap.get("discountInfName"));
        naDiscountInformation.setDiscountAmount(Double.valueOf(paraMap.get("discountAmount")));
        naDiscountInformation.setDiscountDescription(paraMap.get("discountDescription"));
        naDiscountInformation.setUpdater(paraMap.get("userName"));
        naDiscountInformation.setUpdateTime(UtilMethod.unixLong());
        try {
            naDiscountInformationService.update(naDiscountInformation);
        } catch (Exception e) {
            log.error(e.getMessage());
            return ResponseMessage.isSQLException();
        }
        return ResponseMessage.isSuccess("修改优惠信息成功");
    }
}
